import Http from "../../../utils/http.js";


const basic = [{
    title: '变速箱',
    key: "basic",
    code: "gearbox"
  },
  {
    title: '轴距(mm)',
    key: "body",
    code: "wheelBase"
  },
  {
    title: '级别',
    key: null,
    code: "sizeType"
  },
  {
    title: '长(mm)',
    key: "body",
    code: "len"
  },
  {
    title: '宽(mm)',
    key: "body",
    code: "len"
  },
  {
    title: '高(mm)',
    key: "body",
    code: "height"
  },
  {
    title: '整备质量(kg)',
    key: "body",
    code: "weight"
  },
]


const engine = [{
    title: '发动机型号',
    key: "engine",
    code: "model"
  },
  {
    title: '排量',
    key: "engine",
    code: "displacement"
  },
  {
    title: '进气形式',
    key: "engine",
    code: "intakeForm"
  },
  {
    title: '气缸排列型式',
    key: "engine",
    code: "cylinderArrangType"
  },
  {
    title: '气缸数(个)',
    key: "engine",
    code: "cylinderNum"
  },
  {
    title: '每缸气门数(个)',
    key: "engine",
    code: "valveTrain"
  },
  {
    title: '最大马力(Ps)',
    key: "engine",
    code: "maxHorsepower"
  },
  {
    title: '最大功率(kW)',
    key: "engine",
    code: "maxPower"
  },
  {
    title: '最大功率转速(rpm)',
    key: "engine",
    code: "maxPowerSpeed"
  },
  {
    title: '最大扭矩(Nm)',
    key: "engine",
    code: "maxTorque"
  },
  {
    title: '最大扭矩转速(rpm)',
    key: "engine",
    code: "maxTorqueSpeed"
  },
  {
    title: '燃料类型',
    key: "engine",
    code: "fuelType"
  },
  {
    title: '燃油标号',
    key: "engine",
    code: "fuelGrade"
  },
  {
    title: '供油方式',
    key: "engine",
    code: "fuelMethod"
  },
  {
    title: '燃油箱容积(L)',
    key: "engine",
    code: "fuelTankCapacity"
  },
  {
    title: '环保标准',
    key: "engine",
    code: "environmentalStandards"
  },
]

const drivingAuxiliary = [{
    title: '刹车防抱死(ABS)',
    key: "drivingAuxiliary",
    code: "abs"
  },
  {
    title: '电子制动力分配系统(EBD)',
    key: "drivingAuxiliary",
    code: "ebd"
  },
  {
    title: '刹车辅助(EBA/BAS/BA/EVA等)',
    key: "drivingAuxiliary",
    code: "brakeAssist"
  },
  {
    title: '动态稳定控制系统（ESP）',
    key: "drivingAuxiliary",
    code: "esp"
  },
  {
    title: '随速助力转向调节(EPS)',
    key: "drivingAuxiliary",
    code: "eps"
  },
  {
    title: '自动驻车',
    key: "drivingAuxiliary",
    code: "automaticParking"
  },
  {
    title: '上坡辅助',
    key: "drivingAuxiliary",
    code: "hillStartAssist"
  },
  {
    title: '泊车雷达(车前)',
    key: "drivingAuxiliary",
    code: "frontParkingRadar"
  },
  {
    title: '倒车雷达(车后)',
    key: "drivingAuxiliary",
    code: "reversingRadar"
  },
  {
    title: '倒车影像',
    key: "drivingAuxiliary",
    code: "reverseImage"
  },
  {
    title: '定速巡航',
    key: "drivingAuxiliary",
    code: "cruiseControl"
  },
  {
    title: 'GPS导航系统',
    key: "drivingAuxiliary",
    code: "gps"
  },
  {
    title: '夜视系统',
    key: "drivingAuxiliary",
    code: "nightVisionSystem"
  },

]

const chassisBrake = [{
    title: '车体结构',
    key: "chassisBrake",
    code: "bodyStructure"
  },
  {
    title: '转向助力',
    key: "chassisBrake",
    code: "powerSteering"
  },
  {
    title: '前制动类型',
    key: "chassisBrake",
    code: "frontBrakeType"
  },
  {
    title: '后制动类型',
    key: "chassisBrake",
    code: "rearBrakeType"
  },
  {
    title: '驻车制动类型',
    key: "chassisBrake",
    code: "parkingBrakeType"
  },
  {
    title: '驱动方式',
    key: "chassisBrake",
    code: "driveMode"
  },
  {
    title: '空气悬挂',
    key: "chassisBrake",
    code: "airSuspension"
  },
  {
    title: '可调悬挂',
    key: "chassisBrake",
    code: "adjustableSuspension"
  },
  {
    title: '前悬挂类型',
    key: "chassisBrake",
    code: "frontSuspensionType"
  },
  {
    title: '后悬挂类型',
    key: "chassisBrake",
    code: "rearSuspensionType"
  },
  {
    title: '前轮胎规格',
    key: "wheel",
    code: "frontTireSize"
  },
  {
    title: '后轮胎规格',
    key: "wheel",
    code: "rearTireSize"
  }

]

const safe = [{
    title: '主驾驶室安全气囊',
    key: "safe",
    code: "airbagDrivingPosition"
  },
  {
    title: '主驾驶室安全气囊',
    key: "safe",
    code: "airbagFrontPassenger"
  },
  {
    title: '前排侧安全气囊',
    key: "safe",
    code: "airbagFrontSide"
  },
  {
    title: '前排头部气囊',
    key: "safe",
    code: "airbagFrontHead"
  },
  {
    title: '膝部气囊',
    key: "safe",
    code: "airbagKnee"
  },
  {
    title: '后排侧安全气囊',
    key: "safe",
    code: "airbagRearSide"
  },
  {
    title: '后排头部气囊',
    key: "safe",
    code: "airbagRearHead"
  },
  {
    title: '安全带未系提示',
    key: "safe",
    code: "safetyBeltPrompt"
  },
  {
    title: '胎压监测装置',
    key: "safe",
    code: "tirePressureMonitoring"
  },
  {
    title: '中控门锁',
    key: "safe",
    code: "centralLocking"
  },
  {
    title: '儿童锁',
    key: "wheel",
    code: "childLock"
  },
  {
    title: '遥控钥匙',
    key: "safe",
    code: "remoteKey"
  },
  {
    title: '无钥匙进入系统',
    key: "safe",
    code: "keylessEntry"
  },
  {
    title: '无钥匙启动系统',
    key: "safe",
    code: "keylessStart"
  },
  {
    title: '发动机电子防盗',
    key: "engineAntitheft",
    code: "rearTireSize"
  },
  {
    title: '刹车辅助(EBA/BAS/BA/EVA等)',
    key: "safe",
    code: "brakeAssist"
  },

]

const internalConfig = [{
    title: '方向盘前后调节',
    key: "internalConfig",
    code: "steeringWheelBeforeAdjustment"
  },
  {
    title: '方向盘上下调节',
    key: "steeringWheelUpAdjustment",
    code: "airbagFrontPassenger"
  },
  {
    title: '方向盘调节方式',
    key: "internalConfig",
    code: "steeringWheelAdjustmentMode"
  },
  {
    title: '方向盘表面材料',
    key: "internalConfig",
    code: "steeringWheelMaterial"
  },
  {
    title: '多功能方向盘',
    key: "steeringWheelMultiFunction",
    code: "airbagKnee"
  },
  {
    title: '方向盘加热',
    key: "internalConfig",
    code: "steeringWheelHeating"
  },
  {
    title: '行车电脑显示屏',
    key: "internalConfig",
    code: "computerScreen"
  },
  {
    title: 'HUD抬头数字显示',
    key: "internalConfig",
    code: "hudDisplay"
  }

]
const doorMirror = [{
    title: '电动天窗',
    key: "doorMirror",
    code: "electricWindow"
  },
  {
    title: '天窗型式',
    key: "steeringWheelUpAdjustment",
    code: "skylightStype"
  },
  {
    title: '后雨刷器',
    key: "doorMirror",
    code: "rearWiper"
  },
  {
    title: '感应雨刷',
    key: "doorMirror",
    code: "steeringWheelMaterial"
  },
  {
    title: '电动吸合门',
    key: "electricPullDoor",
    code: "airbagKnee"
  },
  {
    title: '外后视镜记忆功能',
    key: "doorMirror",
    code: "externalMirrorMemory"
  },
  {
    title: '外后视镜加热功能',
    key: "doorMirror",
    code: "externalMirrorHeating"
  }

]

Page({

  /**
   * 页面的初始数据
   */
  data: {
    info: "",
    opts: "",
    paramsField:[{
      fieldList:basic,
      name:'基本配置信息'
    },{
      fieldList:engine,
      name:'发动机参数'
    },{
      fieldList:drivingAuxiliary,
      name:'行车辅助配置'
    },{
      fieldList:chassisBrake,
      name:'底盘及制动'
    },{
      fieldList:safe,
      name:'安全配置'
    },{
      fieldList:internalConfig,
      name:'内部配置'
    },{
      fieldList:doorMirror,
      name:'外部配置'
    }],
    detailHighlight: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);

    this.setData({
      detailHighlight: options.detailHighlight,
      opts: options
    })
    Http.request({
      url: '/mall/vehicle/model/id',
      method: 'GET',
      data: {
        id: options.carId
      },
      success: (res) => {
        this.setData({
          info: res
        })
      }
    })
  },

  bindIntroInput: function (e) {
    this.setData({
      detailHighlight: e.detail.value
    })
  },

  bindGetDetailHighlight: function (e) {
    let dataSet = e.currentTarget.dataset;
    let pages = getCurrentPages();
    let prevPage = null; //上一个页面
    if (pages.length >= 2) {
      prevPage = pages[pages.length - 2]; //上一个页面
    }
    prevPage && prevPage.pageConfigDetailHighlight({
      detailHighlight: this.data.detailHighlight
    });
    wx.navigateBack();


  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})